package com.headcaselabs.queue;

import com.headcaselabs.orchestra.Configuration;
import com.xerox.amazonws.sqs.Message;


public class QueueSelectionTester {
	
	public static void main(String[] args) throws Exception {
		Configuration conf = Configuration.getConfiguration(args[0]);
		SQSUtils sqsUtils = new SQSUtils(conf);
		WeightedRoundRobin wrr = new WeightedRoundRobin(sqsUtils.queueParameters,new Object());
		QueueParameters qp = null;
		while ((qp = wrr.nextQueue())!=null) {
			System.out.println(qp.getQueueName());
			Message msg = qp.getQueue().receiveMessage(10);
			if (msg!=null) {
				System.out.println(msg.getMessageId());
				qp.getQueue().deleteMessage(msg.getMessageId());
			}
			sqsUtils.clearQueue(qp.getQueueName());
		}
		while ((qp = wrr.nextQueue())!=null) {
			System.out.println(qp.getQueueName());
		}
		wrr.printQueues();
		wrr.printQueues();
		
	}

}
